#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <iostream>
#include <queue>
#include <time.h>
#include "threadpool.hpp"

bool handler(int data)
{
    srand(time(NULL));
    int n = rand() % 5;
    printf("Thread: %p Run Task: %d --sleep %d sec\n", pthread_self(), data, n);
    sleep(n);
    return true;
}
int main(void)
{
    int i;
    ThreadPool pool;
    pool.PoolInit();
    for (i = 0; i < 10; i++)
    {
        ThreadTask *tt = new ThreadTask(i, handler);
        pool.PushTask(tt);
    }
    pool.PoolQuit();
    return 0;
}
